package com.yanqu.road.server.manager.union;

import com.yanqu.road.pb.rank.RankProto;
import com.yanqu.road.utils.date.DateHelper;

import java.util.ArrayList;
import java.util.List;

public class CrossUnionAbilityRankInfo {
    private long updateTime;
    private int keyId;
    private int centerGroupId;
    private long endTime;
    private List<RankProto.UnionRankTempMsg> rankMsg;

    public CrossUnionAbilityRankInfo(int keyId, int centerGroupId) {
        this.keyId = keyId;
        rankMsg = new ArrayList<>();
        updateTime = DateHelper.getCurrentTime();
        this.centerGroupId = centerGroupId;
    }

    public boolean isNeedUpdate() {
        if (rankMsg.isEmpty()) {
            return true;
        }

        if (DateHelper.getCurrentTime() - updateTime > 10 * DateHelper.SECOND_MILLIONS) { //10秒更新一次
            return true;
        }

        return false;
    }

    public List<RankProto.UnionRankTempMsg> getRankMsg() {
        return rankMsg;
    }

    public void setRankMsg(List<RankProto.UnionRankTempMsg> rankMsg) {
        this.rankMsg = rankMsg;
        this.updateTime = DateHelper.getCurrentTime();
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }

    public int getKeyId() {
        return keyId;
    }

    public int getCenterGroupId() {
        return centerGroupId;
    }
}
